<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 
     创建实例 - 初始化渲染 
      1. 准备容器
      2. 引包-官网 开发版本 - 错误提示更完善
      3. 创建vue实例
      4. 指定配置项
         el 指定挂载点
         data 提供数据
   -->
    <div class="box">
        <div id="app">
            <ul v-for="(item,index) in list">
             <li>
                {{item.numb}}
                <span class="btn" @click="del(item.id)" v-show="item.id>0">删除</span>
             </li>
            </ul>
            <div class="button" @click="add">生成</div>
        </div>
    </div>
    <script src="./vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
              list:[
                {id:1,numb:1},
                {id:2,numb:5},
                {id:3,numb:1}
              ],
              id:0,
              numb:'',
              num:'',
              index:0,
            },
            methods: {
            //    add(){
            //     this.list=this.list.push('1')
            //    }
            add(){
              this.num=Math.floor(Math.random()*(20-1)+1)
              this.list.push({
                id:+new Date(),
                numb:this.num
              })
            },
            del(id){
              this.list=this.list.filter(item=>item.id !=id)
            }
            }
        })
    </script>
</body>
<style>
    .box {
        width: 300px;
        height: 1200px;
        border: 1px solid #000;

        ul li .btn{
           width:100px;
           height:50px;
           background-color: #ccc;
           font-size: 13px;
        }

        .button {
            width: 60px;
            height: 30px;
            background-color: red;
            margin-left: 10px;
            text-align: center;
        }

    }
</style>

</html>